//
//  KCAddStoreCell.swift
//  MyKC
//
//  Created by yy on 2017/4/5.
//  Copyright © 2017年 com.yasuo. All rights reserved.
//

import UIKit

@objc protocol KCAddStoreCellDelegate: NSObjectProtocol {
    @objc optional func addStoreCellDidClick(indexPath: IndexPath)
}

class KCAddStoreCell: UITableViewCell {
    weak var delegate: KCAddStoreCellDelegate?
    lazy var indexPath:IndexPath = IndexPath()
    var model: KCAddXunDianStoreModel? {
        //外界已经完成了的赋值
        didSet {
            lbe_storeName.text = model?.StoreName
            lbe_storeAddress.text = model?.Address
            if model?.IsJoinVisit == "1" {
                switch_isOn.isOn = true
            }else {
                switch_isOn.isOn = false
            }
        }
    }
    @IBOutlet weak var lbe_storeName: UILabel!
    @IBOutlet weak var lbe_storeAddress: UILabel!
    @IBOutlet weak var switch_isOn: UISwitch!
    
    @IBAction func switchBtnClick(_ sender: UISwitch) {
        delegate?.addStoreCellDidClick?(indexPath: indexPath)
        if sender.isOn == true {
            model?.IsJoinVisit = "1"
        }else {
            model?.IsJoinVisit = "0"
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

}
